//
//  COChatDragView.swift
//  CocoProject
//
//  Created by Vill on 2023/11/13.
//

import UIKit

class COChatDragView: WMDragView {

    lazy var statusImg: UIImageView = {
        let img = UIImageView()
        return img
    }()
    
    lazy var priceLbl: UILabel = {
        let price = UILabel()
        price.textColor = .white
        price.textAlignment = .center
        price.backgroundColor = UIColor.gradientFromColor(colors: [UIColor.colorWithHex("#7A73AF").cgColor,UIColor.colorWithHex("#7863A6").cgColor], direction: .Horizontal, range:PTW(88))
        price.layer.cornerRadius = PTW(13)
        price.layer.masksToBounds = true
        return price
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.freeRect = CGRect(x: PTW(10), y: KStatusAndNavBarHeight + PTW(10), width: SCREENWIDTH-PTW(20), height: SCREENHEIGHT - KStatusAndNavBarHeight - KTabBarAndSafeHeight - PTW(100))
        self.isKeepBounds = true
        self.dragDirection = .vertical
        setUpUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setUpUI(){
        addSubview(statusImg)
        addSubview(priceLbl)
        statusImg.snp.makeConstraints { make in
            make.size.equalTo(PTW(65))
            make.centerX.top.equalToSuperview()
        }
        priceLbl.snp.makeConstraints { make in
            make.size.equalTo(CGSizeMake(PTW(88), PTW(26)))
            make.centerX.equalToSuperview()
            make.top.equalTo(statusImg.snp.bottom).offset(PTW(5))
        }
    }
    
    // 设置状态栏
    func setUpStatusImg(str:String){
        statusImg.image = KImaged(str)
    }
    
    //设置价格
    func setUpPriceLbl(price:Int){
        self.priceLbl.attributedText = "\(price)/min".stringWithImage(img: "coco_mine_star", bounds: CGRect(x: 0, y: -PTW(2) , width: PTW(15) , height: PTW(15)), isFirst: true)
    }

}
